<template>
	<view>
		<view v-if="show" class="modalMask">
		</view>
		<view v-if="show" class="modalDialog">
			<view class="modalHint" v-if="title">{{ title }}</view>
			<slot></slot>
			<button class="modalButton" v-if="showConfirm" @click="onConfirm">{{confirmText}}</button>
			<icon class="closeIcon" type="cancel" size="48rpx" color="#666" v-if="showClose" @click="onClose"></icon>
		</view>

	</view>
</template>

<script>
	export default {
		name: "scPopup",
		data() {
			return {
				modalStatus: false,
			};
		},
		props: {
			show: {
				type: Boolean,
				default: false
			},

			// 弹窗默认高度
			height: {
				type: String,
				default: '750'
			},

			// 高度百分比优先级高于height
			percent: {
				type: String,
				default: ''
			},

			// 标题
			title: {
				type: String,
				default: '',
			},

			// 右上角关闭
			showClose: {
				type: Boolean,
				default: true
			},

			// 显示取消按钮
			showCancle: {
				type: Boolean,
				default: true
			},

			// 取消按钮文字
			cancerText: {
				type: String,
				default: '取消'
			},

			// 显示确定按钮
			showConfirm: {
				type: Boolean,
				default: true,
			},

			confirmText: {
				type: String,
				default: '确定'
			},

		},

		methods: {
			onClose() {
				var popup = {
					show: false,
					type: 0
				}
				this.$emit('change', popup)
			},
		}

	}
</script>

<style>
	.modalMask {
		position: fixed;
		width: 100%;
		height: 100%;
		left: 0;
		top: 0;
		background: #000;
		opacity: 0.4;
		overflow: hidden;
		z-index: 998;
		color: #fff;
	}

	.modalDialog {
		position: fixed;
		width: 100%;
		/* height: 624rpx; */
		bottom: 0rpx;
		left: 0rpx;
		padding: 40rpx 60rpx 40rpx 60rpx;
		z-index: 999;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 0rpx 0rpx;
		/* border: 1rpx solid aqua; */
	}

	.closeIcon {
		position: absolute;
		bottom: 240rpx;
		top: 40rpx;
		right: 40rpx;
		width: 48rpx;
		height: 48rpx;
		/* border: 1rpx solid blue; */
		z-index: 999;
	}

	.modalHint {
		color: #343434;
		font-size: 30rpx;
		font-weight: bold;
		padding: 0rpx 0rpx 20rpx 0rpx;
		border-bottom: 1rpx solid #F0F0F0;
	}

	/* /deep/ */
	.modalButton {
		color: #FFFFFF;
		background: #1A76FF;
		font-size: 30rpx;
		/* height: 90rpx; */
		line-height: 90rpx;
		margin: 60rpx 0rpx 10rpx 0rpx;
	}
</style>
